package com.iooiee.adapter_pattern;

import com.iooiee.adapter_pattern.strategy.BinarySearch;
import com.iooiee.adapter_pattern.strategy.QuickSort;

public class OperationAdapter implements ScoreOperation{
    //定义适配者QuickSortd对象
    private QuickSort sortObj;

    //定义适配者BinarySearch对象
    private BinarySearch searchObj;

    public OperationAdapter(){
        sortObj = new QuickSort();
        searchObj = new BinarySearch();
    }


    @Override
    public int[] sort(int[] array) {
        //调用适配者类QuickSort的排序方法
        return sortObj.quickSort(array);
    }

    @Override
    public int serach(int[] array, int key) {
        //调用适配者类的binarySearch的方法
        return searchObj.binarySearch(array, key);
    }
}
